﻿<?php
include_once("./function.php");
//判断是否通过表单提交
if(!isset($_GET["sub"]))
{
	msg("请通过表单提交","./syslogin.php");
	exit;
}
extract($_GET);//$usname $pass $remember
//数据处理
$usname=trim($usname);
$pass=trim($pass);
//判断是否登录成功
$pwd=md5($pass);
$sql="select * from ts_user where username='$usname'";
$res=mysqli_query($link,$sql);
if(is_object($res))
{
	if(mysqli_num_rows($res)>0)
	{
	 $one=mysqli_fetch_assoc($res);
	 if($one['username']=="$usname"&&$one['password']==$pwd&&$one['admin']==1)
	   {  
			setCookie("username",$usname,time()+24*3600*7,"/");
			msg("登录成功","./index.php");exit;
		} 
		else
		{	
			msg("登录失败","./syslogin.php");exit;	
		}
	}
}
?>